﻿#region 命名空间

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WinnerCMS.Model;
using WinnerCMS.Common;
using WinnerCMS.BLL;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Field
{
    [Access("257005")]
    public partial class Manage : WebFactory.PageBase
    {
        private readonly FieldManage _myBLL = new FieldManage();

        private byte ModelId;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.ModelId = byte.Parse(Request.QueryString["ModelId"]);
            if (!IsPostBack)
            {
                var strPath = string.Format("{0} → 自定义字段管理", ModelManage.GetModelName(this.ModelId));
                this.lblPath.Text = strPath;

                BindList(1);
            }
        }

        private void BindList(int PageNo)
        {
            this.GV_List.EmptyDataTemplate = GetTemplate(this);


            var pp = new PagingParam();
            pp.PageNo = PageNo;
            pp.PageSize = this.PageNavigation1.PageSize;
            this.GV_List.DataSource = this._myBLL.BindList(this.ModelId, pp);
            this.GV_List.DataBind();
            this.PageNavigation1.RecordCount = pp.RecordCount;
        }

        protected void PageNavigation1_PageChanging(object src, WebControls.PageChangingEventArgs e)
        {
            BindList(e.NewPageIndex);
        }

        protected void GV_List_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var ID = (int) this.GV_List.DataKeys[e.RowIndex].Value;

            this._myBLL.Delete(this.ModelId, ID, this.UpdatePanel1);


            BindList(1);
        }
    }
}